<!DOCTYPE html>
{% load static %}
<html lang="zh-cn">
<head>
    <script type='text/javascript' src="static/fybjs/htmlAceControlShow.js"></script>
    <script>
        headLoadFile('新一代工业软件应用商店');
    </script>
    <!--付颖斌的js文件-->
    <script type='text/javascript' src="static/fybjs/httpDataTransFyb.js"></script>
    <script>
        $.ajaxSetup({data:{csrfmiddlewaretoken:'{{ csrf_token }}'}})
    </script>
</head>
<body class="no-skin">

<div class="main-container">
    <div class="main-content">
        <div class="row">
            <div class="col-sm-10 col-sm-offset-1">
                <div class="login-container">
                    <div class="center">
                        <h1>
                            <i class="ace-icon fa fa-leaf green"></i>
                            <span class="red">新一代工业软件平台</span>
                            <span class="white" id="id-text2">用户注册</span>
                        </h1>
                    </div>
                    <h4 class="header blue lighter bigger">
                                        <i class="ace-icon fa fa-coffee green"></i>
                                        请输入注册信息
                                    </h4>
                    <div class="space-6"></div>
                    <div class="widget-body" style="width: 100%; border: 1px solid #F0F8FF;">
                                <div class="widget-main">
                                    <!--开始写入正文-->
                                    <form class="form-horizontal" role="form">
                                        <script>
                                            var colName=['role_Name', 'role_str'];
                                            var transData={
                                                table:dbTableHead + 'role_infor',
                                                sqlType:'query',
                                                column:matrixTransStringForSqlColumn(colName),
                                                userAccount:userAccount,
                                                enterAccount:enterAccount,
                                                restraint:'',
                                            };
                                            queryAuthData=dataTransferFyb('getRolList','POST',false,transData,);
                                            var roleNameTemp=[];
                                            var roleStringTemp=[];
                                            for(var i=0;i<queryAuthData.length;i++)
                                            {
                                                roleNameTemp[i]=queryAuthData[i]['role_Name'];
                                                roleStringTemp[i]=queryAuthData[i]['role_str'];
                                            }

                                        </script>
                                        <script>
                                            labelInputShowAceFyb(['用户账号：','form-userAccount-1'],['text','form-userAccount-1','请填入用户账号','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['用户姓名：','form-userName-1'],['text','form-userName-1','请填入用户姓名','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['账号密码：','form-userPass-1'],['password','form-userPass-1','请输入密码！','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['重复密码：','form-userPassRepeat-1'],['password','form-userPassRepeat-1','重复输入密码！','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['用户邮箱：','form-userEmail-1'],['text','form-userEmail-1','请填入用户邮箱','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['用户手机：','form-userPhone-1'],['number','form-userPhone-1','请填入用户手机号','col-xs-10 col-sm-5'],['','']);
                                            labelInputShowAceFyb(['申请角色：','form-userRole-1'],['select','form-userRole-1','用户角色','col-xs-10 col-sm-5'],roleNameTemp);
                                        </script>
                                        <div class="tab-pane" id="ghi">
                                            <div id="submitButtonFyb" class="btn-group btn-group-sm" >
                                                <button type="button" class="btn btn-info" >
                                                    <span class="glyphicon glyphicon-check"></span>提交
                                                </button>
                                            </div>
                                        </div>
                                    </form>

                                    <script>
                                        //写提交按钮事件
                                        var btn = document.getElementById("submitButtonFyb");
                                        btn.onclick =function(){
                                            var userAccount=document.getElementById("form-userAccount-1").valueOf().value;
                                            userAccount=userAccount.replace("'","");//去掉'符号
                                            userAccount=userAccount.replace('"','');//去掉"符号
                                            userAccount=userAccount.replace(',','');//去掉,符号
                                            var userName=document.getElementById("form-userName-1").valueOf().value;
                                            userName=userName.replace("'","");//去掉'符号
                                            userName=userName.replace('"','');//去掉"符号
                                            userName=userName.replace(',','');//去掉,符号
                                            var userPass=document.getElementById("form-userPass-1").valueOf().value;
                                            userPass=userPass.replace("'","");//去掉'符号
                                            userPass=userPass.replace('"','');//去掉"符号
                                            userPass=userPass.replace(',','');//去掉,符号
                                            var userPassRepeat=document.getElementById("form-userPassRepeat-1").valueOf().value;
                                            userPassRepeat=userPassRepeat.replace("'","");//去掉'符号
                                            userPassRepeat=userPassRepeat.replace('"','');//去掉"符号
                                            userPassRepeat=userPassRepeat.replace(',','');//去掉,符号
                                            var userEmail=document.getElementById("form-userEmail-1").valueOf().value;
                                            userEmail=userEmail.replace("'","");//去掉'符号
                                            userEmail=userEmail.replace('"','');//去掉"符号
                                            userEmail=userEmail.replace(',','');//去掉,符号
                                            var userPhone=document.getElementById("form-userPhone-1").valueOf().value;
                                            userPhone=userPhone.replace("'","");//去掉'符号
                                            userPhone=userPhone.replace('"','');//去掉"符号
                                            userPhone=userPhone.replace(',','');//去掉,符号

                                            var selectNode=document.getElementById("form-userRole-1");
                                            var selectIndex=selectNode.selectedIndex;
                                            var nodeAttribute=selectNode.options[selectIndex].value;
                                            if(userPass==userPassRepeat && userPass!=''){
                                                var enterAccount='';//企业唯一ID,这里是用账号作为唯一的id
                                                var transUrl='userRegister';//传输数据的URL
                                                var transType='POST';
                                                var transAsync=false;//表明同步数据传输
                                                var columnName=['user_name','user_account','user_password', 'user_auth','user_email','user_phone'];
                                                var userAuth='';
                                                for(var j=0;j<roleNameTemp.length;j++)
                                                {
                                                    if(nodeAttribute==roleNameTemp[j]){
                                                        userAuth=roleStringTemp[j];
                                                    }
                                                }
                                                var saveDataToBase=[userName,userAccount, userPass,userAuth,userEmail,userPhone];
                                                var transData={
                                                    table:dbTableHead + 'user_infor',
                                                    sqlType:'insert',
                                                    column:matrixTransStringForSqlColumn(columnName),
                                                    saveData:matrixTransStringForSqlColumn(saveDataToBase),//保存数据时，需要保存的数据
                                                    userAccount:userAccount,
                                                    userAccount:userAccount,
                                                    enterAccount:enterAccount,
                                                };
                                                queryData=dataTransferFyb(transUrl,transType,transAsync,transData,);
                                                if(queryData[0]['insert']>0 && queryData[0]['status']=='success'){
                                                    alert('用户创建成功！请登录！');
                                                    window.location.href='login.html'
                                                }else if(queryData[0]['status']=='fail'){
                                                    alert('该账号已存在，请重新输入账号！');
                                                }else{}
                                            }else if(userPass==''){
                                                alert('请输入密码！');
                                            }
                                            else{//
                                                alert('两次密码输入不一致！');
                                            }


                                        }
                                    </script>


                                    <!--结束写入正文-->
                                </div><!-- /.widget-main -->
                            </div><!-- /.widget-body -->

                    <!-- /.position-relative -->
                </div>


            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /.main-content -->



    <!--footer,显示版权信息-->
    <script>
        copyRightAceFyb('长安大学汽车学院物流工程系', 'https://qiche.chd.edu.cn/2020/1208/c8529a173474/page.htm/', '2021');
    </script>
</div><!-- /.main-container -->

</body>
</html>